package eight;

import static util.Print.print;

/**
 * Created by ab on 2016/11/3.
 * 创建一个Cycle类，它具有子类Unicycle、Bicycle和Tricycle。演示
 * 没一个类型的实例都可以经由rid()方法向上转型为Cycle。
 */

class Cycle{
    void run(){
        print("Cycle run");
    }
}

class Unicycle extends Cycle{
    void run(){
        print("Unicycle run");
    }
}

class Bicycle extends Cycle{
    void run(){
        print("Bicycle run");
    }

}

class Tricycle extends Cycle{
    void run(){
        print("Tricycle run");
    }
}

public class task1 {
    public static void test(Cycle c){
        c.run();
    }
    public static void main(String[] args){
        test(new Unicycle());
        test(new Bicycle());
        test(new Tricycle());
    }
}
